package com.zhuiyun.project.api.plan.fitnessType.controller;

import com.zhuiyun.project.annotation.OptLog;
import com.zhuiyun.project.api.plan.fitnessPurpose.service.FitnessPurposeService;
import com.zhuiyun.project.api.plan.fitnessPurpose.entity.FitnessPurpose;
import com.zhuiyun.project.api.plan.fitnessType.entity.FitnessType;
import com.zhuiyun.project.api.plan.fitnessType.service.FitnessTypeService;
import com.zhuiyun.project.common.errorCode.CommonException;
import com.zhuiyun.project.common.response.CommonResult;
import com.zhuiyun.project.utils.constants.CommonConstants;
import com.zhuiyun.project.utils.pageUtil.PageRequest;
import com.zhuiyun.project.utils.pageUtil.PageResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName FitnessActionController
 * @Description TODO
 * @Author ys
 * @Date 2023/11/2 8:48
 **/
@RestController
@RequestMapping("/plan")
public class FitnessTypeController {
    @Autowired
    private FitnessTypeService fitnessTypeService;
    /**
    * @Author 杨珅
    * @Description todo 健身类型查询
    * @Date 2023/11/2 9:28
    * @Return  * @param null
    */
    @PreAuthorize("@ss.hasPermi('plan:fitnessType')")
    @ApiOperation(value = "健身类型查询")
    @OptLog(modular = "健身类型列表", type = CommonConstants.SELECT, describe = "健身类型查询 ")
    @GetMapping("/getFitnessType")
    public CommonResult selectAll(PageRequest pageRequest, String fitnessTypeName,Integer fitnessPurposeId,String venueUniqueIdentifier){
        PageResult pageResult = fitnessTypeService.selectAll(pageRequest,fitnessTypeName,fitnessPurposeId,venueUniqueIdentifier);
        return CommonResult.ok(pageResult);
    }
    /**
     * @Author 杨珅
     * @Description todo 健身类型新增
     * @Date 2023/11/2 9:28
     * @Return  * @param null
     */
    @PreAuthorize("@ss.hasPermi('plan:fitnessType')")
    @ApiOperation(value = "健身类型新增")
    @OptLog(modular = "健身类型列表", type = CommonConstants.ADD, describe = "健身类型新增 ")
    @PostMapping("/addFitnessType")
    public CommonResult insertFitnessType(@RequestBody FitnessType fitnessType)throws CommonException {
        return CommonResult.ok(fitnessTypeService.insertFitnessType(fitnessType));
    }
    /**
     * @Author 杨珅
     * @Description todo 健身类型新增
     * @Date 2023/11/2 9:28
     * @Return  * @param null
     */
    @PreAuthorize("@ss.hasPermi('plan:fitnessType')")
    @ApiOperation(value = "健身类型修改")
    @OptLog(modular = "健身类型列表", type = CommonConstants.UPDATE, describe = "健身类型修改 ")
    @PutMapping("/updateFitnessType")
    public CommonResult updateFitnessType(@RequestBody FitnessType fitnessType)throws CommonException{
        return CommonResult.ok(fitnessTypeService.updateFitnessType(fitnessType));
    }
    /**
     * @Author 杨珅
     * @Description todo 健身类型删除
     * @Date 2023/11/2 9:28
     * @Return  * @param null
     */
    @PreAuthorize("@ss.hasPermi('plan:fitnessType')")
    @ApiOperation(value = "健身类型删除")
    @OptLog(modular = "健身类型列表", type = CommonConstants.DELETE, describe = "健身类型删除 ")
    @DeleteMapping("/deleteFitnessType")
    public CommonResult deleteFitnessType(@RequestBody FitnessType fitnessType){
        return CommonResult.ok(fitnessTypeService.deleteFitnessType(fitnessType));
    }
}
